<template>
  <div class="leftBlock" id="leftBlock">
    <div class="topBtn" @click="topBtn">▲</div>
    <div class="middleCards">
      <ul>
        <li
          v-for="(item,index) in list"
          :key="index"
          v-on:click="chooseCards(item)"
          :class="{ischeck:item.id===current}"
        >
          <div class="cardsBlock">
            <div class="blockTitle">
              <!-- <a href @click.prevent="getData(item)">id:{{ item.id }}</a> -->
              id:{{ item.id }}
            </div>
            <div class="blockContent">name:{{ item.name }}</div>
          </div>
        </li>
      </ul>
    </div>
    <div class="bottomBtn" @click="bottomBtn">▼</div>
  </div>
</template>
<script>
export default {
  // props: ['contractLeft'],
  data() {
    return {
      list: [
        {
          id: '1',
          name: '昨夜雨疏风骤'
        },
        {
          id: '2',
          name: '浓睡不消残酒'
        },
        {
          id: '3',
          name: '试问卷帘人却道海棠依旧'
        },
        {
          id: '4',
          name: '知否'
        },
        {
          id: '5',
          name: '知否'
        },
        {
          id: '6',
          name: '应是绿肥红瘦'
        },
        {
          id: '7',
          name: '...'
        }
      ],
      current: 0,
      num: '',
      srcoll: ''
    }
  },
  mounted() {
    window.addEventListener('scroll', this.menu)
  },
  watch: {
    srcoll: function() {
      this.loadSroll()
    }
  },
  methods: {
    getData(item) {
      // console.log(this.list)
      // this.num = item.id
      // console.log(item)
      // this.$emit('function', item)
    },
    // chooseCards(index) {
    //   this.current = index
    //   console.log(index + '00000')
    // },
    chooseCards(item) {
      this.current = item.id
      console.log(item.id + '00000')
      this.$emit('function', item)
    },
    topBtn() {
      console.log('top')
    },
    bottomBtn() {
      console.log('bottom')
    },
    menu() {
      //获取滚动条的高度
      this.scrollIntoView =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop
      console.log('object :', this.scrollIntoView)
    }
  },
  computed: {
    resultNum() {
      return this.num
    }
  }
}
</script>
<style lang="scss" scoped>
.leftBlock {
  position: relative;
  .topBtn {
    text-align: center;
    line-height: 30px;
    width: 270px;
    height: 30px;
    margin-left: 5px;
    border-radius: 5px 5px 0px 0px;
    position: fixed;
    background-color: rgb(199, 199, 199);
    opacity: 0.2;
    z-index: 888;
    &:hover {
      cursor: pointer;
      opacity: 0.4;
    }
  }
  .middleCards {
    ul {
      padding: 0px 5px 0px 5px;
      margin: 0;
      li {
        list-style: none;
        height: 160px;
        margin-bottom: 5px;
        .cardsBlock {
          border: 1px solid rgb(217, 218, 218);
          width: 100%;
          height: 100%;
          border-radius: 5px;
          .blockTitle {
            font-weight: bold;
          }
          .blockContent {
            font-family: '华文新魏';
          }
          &:hover {
            background-color: rgb(240, 240, 240);
            cursor: pointer;
          }
        }
      }
    }
  }
  .bottomBtn {
    text-align: center;
    line-height: 30px;
    width: 270px;
    margin-left: 5px;
    border-radius: 0px 0px 5px 5px;
    height: 30px;
    position: fixed;
    top: 815px;
    background-color: rgb(199, 199, 199);
    opacity: 0.2;
    z-index: 888;
    &:hover {
      cursor: pointer;
      opacity: 0.4;
    }
  }
  .ischeck {
    background-color: rgb(240, 240, 240);
    color: blue;
  }
}
</style>
